{% extends 'common.html'%}
    {% block content %}

        <div class="weadmin-block buisness_steps">
            <button class="layui-btn" id="refresh_business_steps" data-type="reload">刷新</button>
            <button class="layui-btn" onclick="WeAdminShow('添加步骤','/admin/business_step_add')"><i class="layui-icon"></i>添加步骤</button>
        </div>


        <table class="layui-hide" id="table_business_steps" lay-filter="business_steps"></table>


        <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>

        <script>
            layui.extend({
				admin: '/static/js/admin'
			});
            layui.use(['table','form','admin'], function(){
                var table = layui.table;
                $ = layui.$;
                //方法级渲染
                window.business_step_del  = function (obj,id){
                    layer.confirm('确认要删除吗？', function(index) {
						$.ajax({
                            type: 'post',
                            url: '/admin/business_step_del',
                            data: 'id='+id,
                            success: function(data) {
                                layer.msg(data.message, {
                                    icon: 1,
                                    time: 1000
                                });
                                if(data.code ==1){
                                    $(obj).parents("tr").remove();
                                }

                            }
                        });


					});
                }
                table.render({
                    elem: '#table_business_steps'
                    ,url: '/admin/business_steps'
                    ,method:'post'
                    ,cellMinWidth: 100
                    ,cols: [[
                        {checkbox: true, fixed: true}
                        ,{field:'id', title: 'ID', width:80}
                        ,{field:'name', title: '功能名称',width:120}
                        ,{field:'business', title: '功能代码',width:120}
                        ,{field:'type', title: '功能类型',width:120}
                        ,{field:'var1', title: '变量1'}
                        ,{field:'var2', title: '变量2'}
                        ,{field:'var3', title: '变量3'}
                        ,{field:'var4', title: '变量4'}
                        ,{field:'pre', title: '前置处理'}
                        ,{field:'content', title: '功能代码'}
                        ,{field:'post', title: '后置处理'}
                        ,{field:'sort', title: '排序'}
                        ,{field:'id', title: '操作',templet: function(d){
                            return '<a title="编辑" onclick="WeAdminShow(\'编辑\',\'/admin/business_step_edit?id='+d.id+'\')" href="javascript:;">\n' +
                                '\t\t\t\t\t\t\t\t<i class="layui-icon">&#xe642;</i>\n' +
                                '\t\t\t\t\t\t\t</a>'+
                                '<a title="删除" onclick="business_step_del(this,'+d.id+')" href="javascript:;">\n' +
                                '\t\t\t\t\t\t\t\t<i class="layui-icon">&#xe640;</i>\n' +
                                '\t\t\t\t\t\t\t</a>';
                        }}
                    ]]
                    ,id: 'table_business_steps'
                    ,page: true
                    ,height: 500
                });

                var  active = {
                    reload: function(){
                        table.reload('table_business_steps', {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            }
                            ,where: {
                            }
                        });
                    }

                };
                $('.buisness_steps .layui-btn').on('click', function() {
                    var type = $(this).data('type');
                    active[type] ? active[type].call(this) : '';
                });


            });
        </script>

    {% endblock %}